#include <iostream>
#include "producer_consumer.hpp"

struct MyStruct { int d_[3]; };

int main() {
  constexpr std::size_t kCapacity = 20;
  Common::LFQueue<MyStruct> queue(kCapacity);

  auto consumer = Common::startConsumer<MyStruct>(
      queue,
      [](MyStruct item) {
        std::cout << "consumer got: "
                  << item.d_[0] << ", "
                  << item.d_[1] << ", "
                  << item.d_[2] << '\n';
      });

  for (int i = 0; i < 10; ++i) {
    Common::produce(queue, kCapacity, MyStruct{i, i * 10, i * 100});
    std::cout << "producer push #" << i
              << " size=" << queue.size() << '\n';
  }

  consumer.stop();   // 请求线程退出循环
  consumer.join();   // join + delete

  std::cout << "main done\n";
  return 0;
}